{% extends "_layouts/cp" %}
{% import "_includes/forms" as forms %}
{% set title = "General Settings"|t('app') %}
{% set fullPageForm = true %}

{% set crumbs = [
    { label: "Settings"|t('app'), url: url('settings') }
] %}


{% macro configWarning(setting, file) -%}
    {{ "This is being overridden by the {setting} config setting."|t('app', {
        setting: '<a href="https://craftcms.com/docs/3.x/config/config-settings.html#-'~setting|lower~'" rel="noopener" target="_blank">'~setting~'</a>'
    })|raw }}
{%- endmacro %}

{% from _self import configWarning %}


{% block content %}
    {{ actionInput('system-settings/save-general-settings') }}
    {{ redirectInput('settings') }}

    {{ forms.autosuggestField({
        first: true,
        label: "System Name"|t('app'),
        id: 'name',
        suggestEnvVars: true,
        name: 'name',
        value: system.name
    }) }}

    {{ forms.lightswitchField({
        label: "System Status"|t('app'),
        warning: (craft.app.config.general.isSystemLive is same as(true) or craft.app.config.general.isSystemLive is same as(false) ? configWarning('isSystemLive')),
        id: 'live',
        name: 'live',
        onLabel: 'Online'|t('app'),
        offLabel: 'Offline'|t('app'),
        on: system.live
    }) }}

    {{ forms.textField({
        label: 'Retry Duration'|t('app'),
        instructions: 'The number of seconds that the `Retry-After` HTTP header should be set to for 503 responses when the system is offline.'|t('app'),
        id: 'retry-duration',
        name: 'retryDuration',
        value: system.retryDuration ?? null,
        inputmode: 'numeric',
        size: 4,
    }) }}

    {{ forms.selectField({
        label: "Time Zone"|t('app'),
        warning: (craft.app.config.general.timezone ? configWarning('timezone')),
        id: 'time-zone',
        name: 'timeZone',
        value: system.timeZone,
        options: timezoneOptions
    }) }}

    {% if CraftEdition == CraftPro %}
        <hr>

        {% do view.registerTranslations('app', [
            "Are you sure you want to delete the logo?",
        ]) %}

        {% do view.registerAssetBundle("craft\\web\\assets\\fileupload\\FileUploadAsset") %}

        {{ forms.field({
            label: "Login Page Logo"|t('app'),
            instructions: "SVG file recommended. The logo will be displayed at {size} wide."|t('app', { size: '300px' })
        }, include('settings/general/_images/logo')) }}

        {{ forms.field({
            label: "Site Icon"|t('app'),
            instructions: "Square SVG file recommended. The logo will be displayed at {size} by {size}."|t('app', { size: '32px' })
        }, include('settings/general/_images/icon')) }}

        <div class="clear"></div>
    {% endif %}
{% endblock %}
